home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0034_Reading GIF File Header.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  835b  |  34 lines

  1. {
  2. ERIC MILLER
  3.  
  4. > How does one read/Write a header on a File in TPascal?
  5.  
  6.   Easy.  Write the header structure as a Type.  Then open
  7.   the File as unTyped and blockread the data into a Variable
  8.   of the structure Type.  Take GIFs For example:
  9. }
  10.  
  11. Type
  12.   Gif_Header = Record { first 13 Bytes of a Gif }
  13.     Sig, Ver     : Array[1..3] of Char;
  14.     Screen_X,
  15.     Screen_Y     : Word;
  16.     _Packed,
  17.     Background,
  18.     Pixel_Aspect : Byte;
  19.   end;
  20. Var
  21.   F : File;        { unTyped File }
  22.   G : GIF_Header;
  23. begin
  24.   Assign(F, 'Filename.gif');
  25.   Reset(F, 1);               { blockread in Units of one Byte }
  26.   Blockread(F, G, SizeOf(G));  { read from File }
  27.   Close(F);
  28.   With G DO
  29.   begin
  30.     Writeln('Version: ', Sig, Ver);
  31.     Writeln('Res: ', Screen_X, 'x', Screen_Y, 'x', 2 SHL (_Packed and 7));
  32.   end;
  33. end.
  34.